#include "window.h"

Window::Window(QWidget *parent) :
    QWidget(parent)
{
	inyan = new QSlider;
	lbltxtinyan = new QLabel(tr("Состояние инь-ян"));
	lbltxtreceive = new QLabel("Индикатор принятия информации");
	lbltxtsolve = new QLabel("Решение чего либо");
	lbltxtrecall = new QLabel("Вспоминание из памяти");
	lblimgreceive = new QLabel;
	lblimgsolve = new QLabel;
	lblimgrecall = new QLabel;
	lbltxtedit = new QLabel("&text input");
	lbltxtresponse = new QLabel();
	lbltxtbuffer = new QLabel();
	lbltxtinfocountnode = new QLabel("Колличество узлов");
	lbltxtinfocombination = new QLabel("Колличество комбинаций");
	lbltxtinfocount = new QLabel;
	lbltxtinfocombin = new QLabel;

	lglobal = new QHBoxLayout;
	linyan = new QVBoxLayout;
	lreceive = new QHBoxLayout;
	lsolve = new QHBoxLayout;
	lrecall = new QHBoxLayout;
	lvglob = new QVBoxLayout;
	lvglob2 = new QVBoxLayout;
	ledit = new QHBoxLayout;
	lhcountnode = new QHBoxLayout;
	lhcombin = new QHBoxLayout;

	imgon = new QPixmap;
	imgoff = new QPixmap;

	power = new QPushButton("&Exit");

	input = new QLineEdit;

	//str = new QString;

	lbltxtedit->setBuddy(input);

	inyan->setMinimum(-15);
	inyan->setMaximum(15);
	inyan->setPageStep(1);
	inyan->setValue(0);

	imgon->load("on.png");
	imgoff->load("off.png");

	lbltxtinyan->setAlignment(Qt::AlignCenter);
	lbltxtreceive->setAlignment(Qt::AlignCenter);
	lbltxtsolve->setAlignment(Qt::AlignCenter);
	lbltxtrecall->setAlignment(Qt::AlignCenter);
	lblimgreceive->resize(imgoff->size());
	lblimgreceive->setPixmap(*imgoff);
	lblimgreceive->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
	lblimgsolve->resize(imgoff->size());
	lblimgsolve->setPixmap(*imgoff);
	lblimgsolve->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
	lblimgrecall->resize(imgoff->size());
	lblimgrecall->setPixmap(*imgoff);
	lblimgrecall->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

	lglobal->addLayout(linyan);
	lreceive->addWidget(lbltxtreceive);
	lreceive->addWidget(lblimgreceive);
	lsolve->addWidget(lbltxtsolve);
	lsolve->addWidget(lblimgsolve);
	lrecall->addWidget(lbltxtrecall);
	lrecall->addWidget(lblimgrecall);
	lvglob->addLayout(lreceive);
	lvglob->addLayout(lsolve);
	lvglob->addLayout(lrecall);
	lglobal->addLayout(lvglob);
	lglobal->addWidget(lbltxtinyan);
	lglobal->addWidget(inyan);
	lhcountnode->addWidget(lbltxtinfocountnode);
	lhcountnode->addWidget(lbltxtinfocount);
	lhcombin->addWidget(lbltxtinfocombination);
	lhcombin->addWidget(lbltxtinfocombin);

	lvglob2->addLayout(lglobal);
	lvglob2->addLayout(lhcountnode);
	lvglob2->addLayout(lhcombin);
	lvglob2->addWidget(power);
	ledit->addWidget(lbltxtedit);
	ledit->addWidget(input);
	lvglob2->addWidget(lbltxtresponse);
	lvglob2->addWidget(lbltxtbuffer);
	lvglob2->addLayout(ledit);
	setLayout(lvglob2);
	connect(power, SIGNAL(clicked()), SLOT(close()));
	connect(input, SIGNAL(returnPressed()), SLOT(sendtobuffer()));
	input->setFocus();
	counter = 0;
}
void Window::sendtobuffer()
{
	lbltxtbuffer->setText(input->text());
	ai.receive(input->text());
	lbltxtresponse->setText(ai.getvecstr());
	lbltxtinfocount->setText(ai.getCountNode());
	lbltxtinfocombin->setText(ai.getCombination());
	input->clear();
}

